﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.IO;
using System.Net.Http.Headers;
using System.Configuration;

namespace LibMS.Controllers
{
    [Authorize]
    public class ApiMediaController : ApiController
    {
        private string _localFilePath = ConfigurationManager.AppSettings["BaseDataFolder"];

        [HttpGet]
        public HttpResponseMessage StreamingVideo(string fileName)
        {
            var video = new Models.VideoStream(_localFilePath + fileName);
            var response = Request.CreateResponse();
            response.Content = new PushStreamContent(video.WriteToStream, new MediaTypeHeaderValue("video/mp4"));
            return response;
        }
    }
}
